package dao.impl;

import java.util.List;

import model.Teacher;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

import dao.TeacherDao;

public class TeacherDaoImpl implements TeacherDao{

	private SessionFactory sessionFactory;
	
	public void delTeacher(Teacher teacher) {
		Session session = sessionFactory.getCurrentSession();
		session.delete(teacher);
	}

	public List<Teacher> listTeachers() {
		Session session = sessionFactory.getCurrentSession();
		Query query = session.createQuery("from Teacher");
		List<Teacher> list = query.list();
		return list;
	}

	public void saveOrUpdate(Teacher teacher) {
		Session session = sessionFactory.getCurrentSession();
		session.saveOrUpdate(teacher);
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	
}
